package ntust.tw.embedded_project_v1;

import java.io.ByteArrayInputStream;
import android.content.Context;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter;

public class MySimpleCursorAdapter extends SimpleCursorAdapter {
	private Cursor _cursor;
	private Context _context;
	public MySimpleCursorAdapter(Context context, int layout, Cursor c,
			String[] from, int[] to) {
		super(context, layout, c, from, to);
		_cursor = c;
		_context = context;
	}
	public void bindView(View view, Context context, Cursor cursor) {
		ImageView imageView = (ImageView) view.findViewById(R.id.imgPic);
		
		ByteArrayInputStream stream = new ByteArrayInputStream( 
				_cursor.getBlob(4)); 
		imageView.setImageDrawable(Drawable.createFromStream(stream, "img"));
		super.bindView(view, context, cursor);
	}
}
